<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$basic=$this->plugin_setting('basic');
	set_html('title',$basic['title']?'文章列表-'.$basic['title']:'文章列表');
	$return['sharedata']=array(
		'title'=>$basic['share_title'],
		'desc'=>$basic['share_desc'],
		'link'=>custom_url('jy_wechatnews/mynews//fromuser='.$_SESSION['uid'],true),
		'imgUrl'=>ATTACHMENT_URL.$basic['share_image'],
	);
	$return['params']=array('keyword'=>'');
	if($_RQ['keyword']){
		$return['params']['keyword']=$_RQ['keyword'];
	}
	$return['list']=array();
	exi($return);
}
if($_RQ['op']=='getlist'){
	$return['params']=array();
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],);	
	if($_RQ['keyword']){
		$params['title like']='%'.$_RQ['keyword'].'%';
		$return['params']['keyword']=$_RQ['keyword'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 30;
	$list=pdo_getslice('jy_wechatnews_news',$params,array($pindex,$psize),$total,$fields,'','updatetime desc');
	if($list){
		foreach($list as &$item){
			$item['updatetime']=$item['updatetime']?:$item['createtime'];
			$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
			$item['thumb']=tomedia($item['thumb']);
			$item['listtitle']=pdo_getcolumn('jy_wechatnews_list',array('id'=>$item['listid'],'uniacid'=>$_SESSION['uniacid']),'title');
			$item['merchname']=pdo_getcolumn('jy_merch_user',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['merchid']),'merchname');
			$item['typetitle']=$this->news_type[$item['type']];
			$item['statustitle']=$this->news_status[$item['status']];
		}
	}
	$return['list']=$list;
	$return['params']['page'] =$pindex;
	exi($return);
}
if($_RQ['op']=='fabu'){
	if(!$_RQ['id']){
		exi('文章不存在哦！','error');
	}
	pdo_update('jy_wechatnews_news',array('status'=>2),array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	exi('提交成功！','','/mynews/');
}